using Assets.Scripts.GDK;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class ShopAdItem : gdk_base_layer
	{
		public RectTransform btn;

		public Text MoneyText;

		public GameObject adBtnBG;

		private GameShopModel myGiftInfo;

		public void OnData(GameShopModel gameShopModel, Action callback)
		{
			myGiftInfo = gameShopModel;
			OnUIUpdate();
			btn.GetComponent<Button>().onClick.AddListener(delegate
			{
				gdk_game_manager.PlaySound(AudioID.click);
				if (gameShopModel.shopID == 900)
				{
					GameManager.PlayAdvert(Advans.SHOPPLAY, "4", delegate
					{
						gdk_game_manager.log("视频完成");
						GameManager.addCoin(gameShopModel.coin);
						GameData.dayLookAd++;
						OnUIUpdate();
					}, delegate
					{
						gdk_game_manager.log("广告遇到其它类型错误失败");
					}, delegate
					{
						gdk_game_manager.log("视频取消");
					}, string.Empty);
				}
				else
				{
					callback();
				}
			});
		}

		public void OnUIUpdate()
		{
			if (GDK.ModuleManger.Module<ShopPanelModule>().GetLookAdCount() >= 5)
			{
				MoneyText.text = "next day";
				adBtnBG.SetActive(value: false);
				btn.GetComponent<Button>().interactable = false;
			}
			else
			{
				btn.GetComponent<Button>().interactable = true;
				adBtnBG.SetActive(value: true);
				MoneyText.text = string.Empty;
			}
		}
	}
}

